//
//  UpHotOrderView.m
//  WuyouTang
//
//  Created by ybRRR on 2023/7/12.
//  Copyright © 2023 cat. All rights reserved.
//

#import "UpHotOrderView.h"

@interface UpHotOrderView ()
{
    UIView *backView;
}
@end

@implementation UpHotOrderView

-(instancetype)initWithFrame:(CGRect)frame andInfoDic:(NSDictionary *)infoDic
{
    self = [super initWithFrame:frame];
    if(self){
        self.backgroundColor = RGBA(1, 1, 1, 0.4);
        
        backView = [[UIView alloc]init];
        backView.frame = CGRectMake(0, 0, _window_width *0.6, _window_width *0.6*0.7);
        backView.backgroundColor = UIColor.whiteColor;
        backView.center = self.center;
        backView.layer.cornerRadius = 10;
        backView.layer.masksToBounds = YES;
        [self addSubview:backView];
        
        UILabel *titleLb = [[UILabel alloc]init];
        titleLb.font = [UIFont systemFontOfSize:16];
        titleLb.textColor = UIColor.blackColor;
        titleLb.text = YZMsg(@"您还有一个上热门未使用");
        [backView addSubview:titleLb];
        [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(backView.mas_centerX);
            make.top.equalTo(backView.mas_top).offset(10);
        }];
        
        UILabel *coinLbT = [[UILabel alloc]init];
        coinLbT.font = [UIFont systemFontOfSize:14];
        coinLbT.textColor = UIColor.grayColor;
        coinLbT.text = YZMsg(@"投放金额");
        [backView addSubview:coinLbT];
        [coinLbT mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(backView.mas_left).offset(40);
            make.top.equalTo(titleLb.mas_bottom).offset(10);
        }];
        
        UILabel *pushT = [[UILabel alloc]init];
        pushT.font = [UIFont systemFontOfSize:14];
        pushT.textColor = UIColor.grayColor;
        pushT.text = YZMsg(@"曝光量");
        [backView addSubview:pushT];
        [pushT mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(coinLbT.mas_left);
            make.top.equalTo(coinLbT.mas_bottom).offset(10);
        }];
        UILabel *numT = [[UILabel alloc]init];
        numT.font = [UIFont systemFontOfSize:14];
        numT.textColor = UIColor.grayColor;
        numT.text = YZMsg(@"预计进场人数");
        [backView addSubview:numT];
        [numT mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(pushT.mas_left);
            make.top.equalTo(pushT.mas_bottom).offset(10);
        }];

        UILabel *coinLb = [[UILabel alloc]init];
        coinLb.font = [UIFont systemFontOfSize:14];
        coinLb.textColor = UIColor.grayColor;
        coinLb.text = minstr([infoDic valueForKey:@"coin"]);
        [backView addSubview:coinLb];
        [coinLb mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(numT.mas_right).offset(10);
            make.centerY.equalTo(coinLbT.mas_centerY);
        }];

        
        UILabel *pushLb = [[UILabel alloc]init];
        pushLb.font = [UIFont systemFontOfSize:14];
        pushLb.textColor = UIColor.grayColor;
        pushLb.text = minstr([infoDic valueForKey:@"exposure"]);
        [backView addSubview:pushLb];
        [pushLb mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(numT.mas_right).offset(10);
            make.centerY.equalTo(pushT.mas_centerY);
        }];

        UILabel *numLb = [[UILabel alloc]init];
        numLb.font = [UIFont systemFontOfSize:14];
        numLb.textColor = UIColor.grayColor;
        numLb.text =[NSString stringWithFormat:@"%@-%@",minstr([infoDic valueForKey:@"user_min_num"]),minstr([infoDic valueForKey:@"user_max_num"])];
        [backView addSubview:numLb];
        [numLb mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(numT.mas_right).offset(10);
            make.centerY.equalTo(numT.mas_centerY);
        }];

        [self layoutIfNeeded];
        
        [PublicObj lineViewWithFrame:CGRectMake(0, backView.height-46, backView.width, 1) andColor:RGBA(240, 240, 240, 1) andView:backView];
        [PublicObj lineViewWithFrame:CGRectMake(backView.width/2, backView.height-46, 1, 46) andColor:RGBA(240, 240, 240, 1) andView:backView];
        
        UIButton *cancelBtn = [UIButton buttonWithType:0];
        cancelBtn.frame = CGRectMake(0, backView.height-45, backView.width/2, 45);
        [cancelBtn setTitle:YZMsg(@"取消") forState:0];
        [cancelBtn setTitleColor:UIColor.grayColor forState:0];
        cancelBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [cancelBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [backView addSubview:cancelBtn];
       
        UIButton *sureBtn = [UIButton buttonWithType:0];
        sureBtn.frame = CGRectMake(backView.width/2, backView.height-45, backView.width/2, 45);
        [sureBtn setTitle:YZMsg(@"使用") forState:0];
        [sureBtn setTitleColor:Pink_Cor forState:0];
        sureBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [sureBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [backView addSubview:sureBtn];

    }
    return self;
}
-(void)btnClick:(UIButton *)sender{
    if(self.btnEvent){
        self.btnEvent(sender.titleLabel.text);
    }
}
@end
